#include<bits/stdc++.h>
#define int long long
#define INF (0x3f3f3f3f3f3f3f3f)
using namespace std;


signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    cin>>T;//单个输入把我这行禁用！！！
    string s;
    string s_temp;
    vector<pair<string, int>> v;
    while(T--){
        s="";
        for(int i=1;i<=8;i++)
        {
            cin>>s_temp;
            s+=s_temp;
        }
        int flag=0;
        for (auto & i : v)
        {
            if (s==i.first)
            {
                i.second+=1;
                cout<<i.second<<endl;
                flag=1;
                break;
            }
        }
        if (flag==0)
        {
            v.emplace_back(s,1);
            cout<<1<<endl;
        }
    }
    return 0;
}